/**
 * 
 */
package cn.ad.param;


import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.HashMap;

/**
 * 订单查询参数
 * 
 * @author yujuan.zhang
 * @from 2016-06-13
 * @since V1.0
 *
 */
public class ReportListQuery extends AbstractPagingSortParam {

	/**
	 * 搜索关键词， 订单名称或者ID
	 */
	private String search;

	/**
	 * 订单状态
	 */
	private Integer status;

	/**
	 * KPI 类型
	 */
	private Integer feeType;

	/**
	 * 所属广告主ID
	 */
	private Integer advertiserId;

	/**
	 * 数据报告查询-开始时间
	 */
	@NotNull
	@NotEmpty
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date startTime;
	
	/**
	 * 数据报告查询-结束时间
	 */
	@NotNull
	@NotEmpty
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date endTime;
	/**
	 * @return the search
	 */
	public String getSearch() {
		return search;
	}

	/**
	 * @param search
	 *            the search to set
	 */
	public void setSearch(String search) {
		this.search = search;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getFeeType() {
		return feeType;
	}

	public void setFeeType(Integer feeType) {
		this.feeType = feeType;
	}

	public Integer getAdvertiserId() {
		return advertiserId;
	}

	public void setAdvertiserId(Integer advertiserId) {
		this.advertiserId = advertiserId;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	/**
	 * 默认按id排序
	 */
	@Override
	public String getSortby() {
		return StringUtils.isEmpty(super.getSortby()) ? "id" : super.getSortby();
	}

	/**
	 * 默认按降序排序
	 */
	@Override
	public ORDER getOrder() {
		return super.getOrder() == null ? ORDER.desc : super.getOrder();
	}
	

	public HashMap<String, Object> getSearchMap(){
		HashMap<String, Object> map = new HashMap<String,Object>(5);
		map.put("search", this.search);
		map.put("advertiserId", advertiserId);
		map.put("status", status);
		return map;
	}

}
